FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

SRC_URI += "\
            file://0001-cpld-update-Add-cpld-update-support.patch \
            file://update-cpld.sh \
            file://bios_flash.sh \
            file://progress_monitoring.sh \
            "

RDEPENDS:${PN}-updater += "bash"
SYSTEMD_ENVIRONMENT_FILE:${PN}-updater:append := " obmc/update"

PACKAGECONFIG[update-cpld] = "-Dhost-cpld-upgrade=enabled, -Dhost-cpld-upgrade=disabled"
PACKAGECONFIG:append = " update-cpld flash_bios"

SYSTEMD_SERVICE:${PN}-updater += "${@bb.utils.contains('PACKAGECONFIG', 'update-cpld', 'obmc-update-cpld@.service', '', d)}"
RDEPENDS:${PN}-updater += "${@bb.utils.contains('PACKAGECONFIG', 'update-cpld', 'loadsvf', '', d)}"

do_install:append() {
    # intsall cpld update script
    install -m 0755 ${WORKDIR}/update-cpld.sh ${D}/usr/local/update-cpld.sh

    # intsall bios update script
    install -m 0755 ${WORKDIR}/bios_flash.sh ${D}/usr/local/bios_flash.sh
    install -m 0755 ${WORKDIR}/progress_monitoring.sh ${D}/usr/local/progress_monitoring.sh
}
